import glob
import cv2
import os

# leve0_list = glob.glob('./raw_data/0/*.tif')
leve1_list = glob.glob('./raw_data/1/*.tif')
leve2_list = glob.glob('./raw_data/2/*.tif')
leve3_list = glob.glob('./raw_data/3/*.tif')
leve4_list = glob.glob('./raw_data/4/*.tif')
leve5_list = glob.glob('./raw_data/5/*.tif')
leve6_list = glob.glob('./raw_data/6/*.tif')


if not os.path.exists('./real_data'):
    os.makedirs('./real_data')
    # os.makedirs('./real_data/level_0')
    os.makedirs('./real_data/1')
    os.makedirs('./real_data/2')
    os.makedirs('./real_data/3')
    os.makedirs('./real_data/4')
    os.makedirs('./real_data/5')
    os.makedirs('./real_data/6')

# if not os.path.exists('./grey_data'):
#     os.makedirs('./grey_data')
#     os.makedirs('./grey_data/level_1')
#     os.makedirs('./grey_data/level_2')
#     os.makedirs('./grey_data/level_3')

# print(leve1_list)


# for i, img_path in enumerate(leve0_list):
#     img = cv2.imread(img_path)[:-77, :, :]
#     cv2.imwrite(f'./real_data/level_0/{i}.tif', img)

for i, img_path in enumerate(leve1_list):
    img = cv2.imread(img_path)[:-77, :, :]
    cv2.imwrite(f'./real_data/1/{i}.tif', img)

for i, img_path in enumerate(leve2_list):
    img = cv2.imread(img_path)[:-77, :, :]
    cv2.imwrite(f'./real_data/2/{i}.tif', img)

for i, img_path in enumerate(leve3_list):
    img = cv2.imread(img_path)[:-77, :, :]
    cv2.imwrite(f'./real_data/3/{i}.tif', img)

for i, img_path in enumerate(leve4_list):
    img = cv2.imread(img_path)[:-77, :, :]
    cv2.imwrite(f'./real_data/4/{i}.tif', img)

for i, img_path in enumerate(leve5_list):
    img = cv2.imread(img_path)[:-77, :, :]
    cv2.imwrite(f'./real_data/5/{i}.tif', img)

for i, img_path in enumerate(leve6_list):
    img = cv2.imread(img_path)[:-77, :, :]
    cv2.imwrite(f'./real_data/6/{i}.tif', img)

# for i, img_path in enumerate(male_list):
#     img = cv2.imread(img_path)[60:1060, 1400:1850, :]
#     cv2.imwrite(f'./real_data/male/{i}.jpg', img)
#
# for i, img_path in enumerate(female_list):
#     img = cv2.imread(img_path, cv2.IMREAD_GRAYSCALE)[60:1060, 1400:1850]
#     cv2.imwrite(f'./grey_data/female/{i}.jpg', img)
# for i, img_path in enumerate(male_list):
#     img = cv2.imread(img_path, cv2.IMREAD_GRAYSCALE)[60:1060, 1400:1850]
#     cv2.imwrite(f'./grey_data/male/{i}.jpg', img)

